<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <title>mini秀后台</title>
    <script language="javascript" type="text/javascript" src="/admin/js/jquery-3.1.1.js"></script>
    <script src="/admin/js/common.js"></script>
    <style>
        body { margin: 0; padding: 0; font-family: '微软雅黑', Verdana, Arial, Helvetica, sans-serif;}
        .login_bg { width: 100%; height: 200px; background: #249D80; padding-top: 200px;}
        .login_text { width: 200px; height: 30px; margin: 0 auto; font-size: 25px; color: #fff;}
        .login-box { width: 400px; height: auto; margin: 40px auto; background: #fff; padding: 40px 0;}
        .login_row { width: 80%; height: 50px; margin: 0 auto;}
        .login_row span { display: inline-block; vertical-align: middle; width: 60px; height: 40px; line-height: 40px; font-size: 13px; color: #6b6b6b;}
        .login_row input[type='text'] { display: inline-block; width: 235px; height: 30px; border: 1px solid #ccc; padding-left: 15px;}
        .login_row input[type='password'] { display: inline-block; width: 235px; height: 30px; border: 1px solid #ccc; padding-left: 15px;}
        .login_row input[type='submit'] { display: inline-block; vertical-align: middle; width: 80px; height: 30px; border: 1px solid #ccc; background: #249D80; color: #fff;}
        .login_errpr { display: none; width: 80%; height: 25px; color: #d9534f; margin: 0 auto;}
    </style>
</head>
<body style="background: #eee;">
<div class="login_bg">
    <div class="login_text">
        MINI秀直播系统
    </div>
    <div class="login-box">
        <div class="login_row">
            <span>用户名</span>
            <input type="text" id="adminame">
        </div>
        <div class="login_row">
            <span>密码</span>
            <input type="password" id="pass">
        </div>
        <div class="login_row">
            <span>验证码</span>
            <input type="text" id="code" style="width: 80px; vertical-align: middle; margin-right: 15px;">
            <img src="/admin/captcha" alt="" style="vertical-align: middle;">
        </div>
        <div class="login_errpr" id="loginerr">
            管理用户或密码错误！
        </div>
        <div class="login_row">
            <span></span>
            <input type="submit" value="登录" onclick="doLogin(this)">
        </div>
    </div>
</div>
</body>
</html>
<script>

    function showerr(html) {
        var error = document.getElementById('loginerr');
        error.style.display ='block';
        error.innerHTML = html;
    }

    function doLogin(_this) {
        var adminame = document.getElementById('adminame')
        var pass = document.getElementById('pass')
        var code = document.getElementById('code')
        if (adminame.value=='' || pass.value=='') {
            showerr('用户名或密码不能为空！');
            return;
        }
        var data = {};
        data.username = adminame.value;
        data.pass = pass.value;
        data.code = code.value;
        $.ajax({
            type:"POST",
            url:"/admin/dologin",
            data:data,
            dataType:"json",
            success:function (res) {
                if (res['code']==200) {
                    _this.value = '登录中……';
                    window.location.href = res.url;
                }else{
                    showerr(res.msg);
                }
            }
        })
    }
</script>